package com.zhuoyue.biz.core.command.cmd.common.faa;

import com.zhuoyue.biz.core.api.domain.DeviceAndGatewayDO;
import com.zhuoyue.biz.core.api.dto.req.ControlReq;
import com.zhuoyue.biz.core.command.cmd.common.faa.base.SetCmd;
import com.zhuoyue.common.constant.ControlType;
import com.zhuoyue.common.constant.DataBase;


/**
 * 米提尔场景面板(带雷达功能)
 *
 * @author wjming
 */
public class SixRoadScenePanelMte0Faa8A05 extends SetCmd {
    private static Integer setRoad = null;

    /**
     * @param deviceAndGatewayDO
     * @param controlReq         actions:{
     *                           "sceneId":xxxxx,
     *                           "setRoad":1
     *                           "setRadar":"10"
     *                           }
     *                           controlType:"SCENE_SET_REQUEST"//SceneSetRequest场景配置请求
     * @param code3
     * @return
     */
    public static String set(DeviceAndGatewayDO deviceAndGatewayDO, ControlReq controlReq, String code3) {
        String cmd = "";
        switch (controlReq.getControlType()) {
            //场景配置
            case ControlType.Set.SCENE_SET_REQUEST:
                cmd = getControlCmd(deviceAndGatewayDO, sceneSet(code3));
                break;
            //雷达配置
            case ControlType.Set.RADAR_SET_REQUEST:
                String setRadar = controlReq.getActions().get("setRadar").toString();
                cmd = getControlCmd(deviceAndGatewayDO, radarSet(setRadar));
                break;
            default:
                break;
        }
        return cmd;
    }

    private static String radarSet(String setRadar) {
        return "14" + DataBase.DATA_LENGTH_01 + setRadar;
    }

    private static String sceneSet(String code) {
        return setRoad < 10 ? 0 + "setRoad" : setRoad + "" + DataBase.DATA_LENGTH_12 + code + "0000000000000000000000000000000000";
    }

}
